package com.chenl.interview.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chenl.interview.model.dto.question.QuestionAddRequest;
import com.chenl.interview.model.dto.question.QuestionQueryRequest;
import com.chenl.interview.model.entity.Question;
import com.baomidou.mybatisplus.extension.service.IService;
import com.chenl.interview.model.entity.User;
import com.chenl.interview.model.vo.QuestionVO;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.List;

/**
* @author chenl
* @description 针对表【question(题目)】的数据库操作Service
* @createDate 2024-12-29 15:33:22
*/
public interface QuestionService extends IService<Question> {

    void validQuestion(Question question, boolean add);
    Long addQuestion(QuestionAddRequest questionAddRequest);

    QuestionVO getQuestionVOById(User user, Long id);

    boolean updateQuestion(Question question);

    /**
     * 获取查询条件
     *
     * @param questionQueryRequest
     * @return
     */
    QueryWrapper<Question> getQueryWrapper(QuestionQueryRequest questionQueryRequest);

    Page<QuestionVO> getQuestionVOPage(Page<Question> questionPage);

    /**
     * 从Es查询数据
     * @param questionQueryRequest
     * @return
     */
    Page<QuestionVO> searchFromEs(QuestionQueryRequest questionQueryRequest);

    /**
     * 检查用户有无权限访问仅会员可见的题目并做相关处理
     */
    void withVipPrivileges(QuestionVO questionVO);

    /**
     * 增量同步数据到ES
     */
    void incSyncQuestionToEs(List<Long> ids);
}
